﻿#ifndef LOGIN_H
#define LOGIN_H

#include <QWidget>
#include <QTcpSocket>
#include "signup.h"
#include "chatroom.h"

namespace Ui {
class Login;
}

class Login : public QWidget
{
    Q_OBJECT

public:
    explicit Login(QWidget *parent = nullptr);
    ~Login();

    // 发送到服务器
    void WriteToServer(const QJsonObject &obj);

    // 处理json逻辑
    void process(const QByteArray& data);

signals:
    void transfer(QTcpSocket *socket);

    void sendFromName(const QString &fromName);

    void SetSocket(QTcpSocket *socket);

private slots:
    void on_pushButton_signup_clicked();

    void ShowLoginFace();

    void on_pushButton_login_clicked();

    void ReadData();

    void ExitChat();

private:
    Ui::Login *ui;
    QTcpSocket *socket;
    SignUp * signup;
    QByteArray buffer; // 自定义缓冲区
    ChatRoom * chatroom;
};

#endif // LOGIN_H
